/**
 * Created by qiaozhi on 16/5/4.
 */
var wdui = {
    scopes: [],
    init: function () {
        var scopes = document.querySelectorAll("wd-scope");
        for (var i = 0; i < scopes.length; i++) {
            var btns = scopes[i].querySelectorAll("wd-button");

            //事件绑定
            console.log(btns[0].attributes);

            var clickBind = btns[0].getAttribute("wd-click");
            btns[0].removeAttribute("wd-click");
            btns[0].onclick = function (e) {
                eval(clickBind + "(e)");
            }

            //添加实例
            wdui.scopes.push({
                dom: scopes[i],
                children: {
                    btn: []
                }
            });

            btns[0].setAttribute("wd-instance", "wd_" + new Date().getTime());
        }
    }
}
wdui.init();

function aaa(e) {
    alert(e);
}

//各组件继承公共类
//_instanceID, create update remove方法可公用

//内部新增的元素注册事件用事件冒泡
//dom被人为销毁的情况处理

/*
 <wd-scope>
 <wd-button wd-click="aaa">测试</wd-button>
 </wd-scope>
 */